package com.topway.dsmflex.ui.labelProvider;

import org.eclipse.jface.viewers.ITableLabelProvider;

import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;

import com.Application;
import com.swtdesigner.SWTResourceManager;
import com.topway.dsmflex.model.servers.DataServerBean;
/**
 * 
 * @author liusy 2013-04-28
 *
 */
public class ServersMonitorProvider extends LabelProvider implements ITableLabelProvider {

	
   public Image getColumnImage(Object element, int columnIndex) {
	   DataServerBean dt = (DataServerBean) element;
	   if(columnIndex==1)
	   {
			switch (dt.getServerState()) {
				case 0:
					return SWTResourceManager.getImage(Application.class,
							"/img/grey.png");
				case 1:
					return SWTResourceManager.getImage(Application.class,
							"/img/green.png");
				case 2:
					return SWTResourceManager.getImage(Application.class,
							"/img/red.png");
			}
	   }
	   
      return null;
   }

   public String getColumnText(Object element, int columnIndex) {
	   DataServerBean dt = (DataServerBean) element;
	  
      switch (columnIndex) {
      case 0:
         return "";
      case 1:
    	   return "";//dt.getState()==0?"停止":"运行";
      case 2:
    	  return dt.getName();
      case 3:
    	  return dt.getEnabled()==1?"是":"否";
      case 4:
    	  return dt.getIp();
      case 5:
    	  return dt.getRemark();
	   }
      return null;
   }   
}
